home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: March 19, 1997
- //
- // Description:
- // An option window used to create a named set, and (if desired) add
- // it to a partition.
- //
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- // The variables in this "option" box are not options because
- // bug reports (84564) indicated that users did not want the options
- // to carry over from session to session.
- //
- }
-
- //
- // Procedure Name:
- // createSetSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc createSetSetup(string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars( $forceFactorySettings );
-
- setParent $parent;
-
- checkBoxGrp -edit -value1 0 partitionWidget;
- checkBoxGrp -edit -value2 0 partitionWidget;
- optionMenuGrp -e -enable 0 partitionListWidget;
-
- textFieldGrp -e -text "set1" setNameWidget;
- }
-
- //
- // Procedure Name:
- // createSetCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc createSetCallback(string $parent, int $doIt)
- {
- setParent $parent;
-
- if ($doIt) {
- performCreateSet 0;
- addToRecentCommandQueue "performCreateSet 0" "Create Set";
- }
- }
-
- //
- // Procedure Name:
- // createSetOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc createSetOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "createSet";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- // Any default option box behaviour based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName("sets");
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // STEP 4: Create option box contents.
- // ===================================
- //
- // This, of course, will vary from option box to option box.
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -tabsVisible 0 -scrollable 1;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // name for the set
- //
- formLayout nameLayout;
- textFieldGrp
- -label "Name"
- setNameWidget;
- setParent ..;
-
- separator;
-
- // whether or not the set should be added to partition(s)
- checkBoxGrp
- -label "Add to a Partition:"
- -label1 "Only If Exclusive"
- -label2 "By Making Exclusive"
- -numberOfCheckBoxes 2
- -on1 "optionMenuGrp -e -enable 1 partitionListWidget; checkBoxGrp -e -value2 0 partitionWidget;"
- -on2 "optionMenuGrp -e -enable 1 partitionListWidget; checkBoxGrp -e -value1 0 partitionWidget;"
- -offCommand "optionMenuGrp -e -enable 0 partitionListWidget"
- partitionWidget;
-
- // Create an option menu listing the partitions
- //
- optionMenuGrp -l "Partition" partitionListWidget;
-
- // add all the partitions to the menu
- //
- int $pp;
- string $partitionArray[];
- $partitionArray = `ls -type partition`;
- int $partitionCount = size($partitionArray);
- for ($pp = 0; $pp < $partitionCount; $pp++)
- {
- // Do not list the render or character partitions as
- // adding items to them is only going to cause confusion.
- //
- if ( ($partitionArray[$pp] != "renderPartition") &&
- ($partitionArray[$pp] != "characterPartition") )
- {
- menuItem -l $partitionArray[$pp];
- }
- }
- setParent $parent;
-
- separator;
-
- optionMenuGrp -e -enable false partitionListWidget;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("Create Set Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "CreateSet" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // createSetHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string createSetHelp()
- {
-
- return
- " Command: sets - Creates a new set.\n" +
- "Selection: Selected items are placed in the set.";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "optionBoxExample1";
-
- setOptionVars(false);
-
- // get the partition name
- string $setName = "set1";
- if (`textFieldGrp -exists setNameWidget`) {
- $setName = `textFieldGrp -q -text setNameWidget`;
- }
-
- int $addState = 0;
- if (`checkBoxGrp -exists partitionWidget`) {
- if (`checkBoxGrp -q -value1 partitionWidget`) {
- $addState = 1; // try to add
- } else if (`checkBoxGrp -q -value2 partitionWidget`) {
- $addState = 2; // force add
- }
- }
-
- string $partitionName = "";
- if (`optionMenuGrp -exists partitionListWidget`) {
- $partitionName = `optionMenuGrp -q -v partitionListWidget`;
- }
-
- // create the sets command string
- if (size($setName)) {
- $cmd = "$createSetResult = `sets -name "+$setName;
- } else {
- $cmd = "$createSetResult = `sets";
- }
-
- // if we are going to forcibly add the items to a partition
- // then make an empty set first. Later we'll force the items
- // into our set.
- //
- if ($addState == 2) {
- $cmd += " -em";
- }
-
- $cmd += "`;";
-
- //
- // put the set into the partition
- //
- if ($addState != 0) {
- $cmd += " partition -e -addSet " + $partitionName+" $createSetResult;";
- }
-
- //
- // If the addState is "force to add", force the selected items
- // into the set. This will remove the items from the other set(s)
- // in the partition if necessary since the set has already been
- // added to the partition.
- //
- if ($addState == 2) {
- $cmd += " sets -edit -forceElement $createSetResult;";
- }
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performCreateSet
- //
- // Description:
- // Perform the create set command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the optionBoxExample1 command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- global proc string performCreateSet(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
- //
- evalEcho($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- createSetOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-